﻿using System.CodeDom;
using Roslyn.Compilers.CSharp;

namespace InterfaceWeaver.CustomTool
{
    public sealed class EventDeclaration
    {
        private readonly EventDeclarationSyntax @event = null;

        /// <summary>
        /// Initializes a new instance of the <see cref="EventDeclaration" /> class.
        /// </summary>
        /// <param name="event">The event.</param>
        public EventDeclaration(EventDeclarationSyntax @event)
        {
            this.@event = @event;
        }

        /// <summary>
        /// Creates the code event implementation.
        /// </summary>
        /// <returns></returns>
        public CodeMemberEvent CreateCodeEventImplementation()
        {
            var weavedEvent = new CodeMemberEvent
                {
                    Name = this.@event.Identifier.ValueText,
                    Type = this.@event.Type.ToTypeReference()
                };

            return weavedEvent;
        }
    }
}
